package com.oa.co.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oa.co.mapper.RoomMapper;
import com.oa.co.pojo.Room;
import com.oa.co.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Lone Ranger
 */
@Service("RoomService")
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomMapper roomMapper;


    @Override
    public PageInfo<Room> getAllRoom(Integer page, Integer limit, Integer floor, Integer room_status) {

        Room room = new Room();
        room.setFloor(floor);
        room.setRoom_status(room_status);

        // 传入页码和每页记录数
        PageHelper.startPage(page, limit);
        List<Room> roomList = roomMapper.findRoomByCondition(room);
        PageInfo<Room> pageInfo = new PageInfo<>(roomList);

        return pageInfo;
    }

    @Override
    public List<Room> getRooms() {
        return roomMapper.getAllRoom();
    }

//    @Override
//    public Integer addRoom(String room_name, Integer floor, Integer max_num) {
//        return roomMapper.addRoom(room_name,floor,max_num,0);
//    }
    @Override
    public Integer addRoom(Room room) {
        return roomMapper.addRoom(room);
    }

    @Override
    public Integer deleteRoom(Integer room_id) {
        return roomMapper.deleteRoom(room_id);
    }

    @Override
    public Integer updateRoom(Room room) {
        return roomMapper.updateRoom(room);
    }

    @Override
    public Integer deleteRoomMulti(List<Room> list) {
        return roomMapper.deleteRoomMulti(list);
    }
}
